//
//  HTTruckCollectionCell.m
//  TruckDriver
//
//  Created by Ting Han on 2017/10/12.
//  Copyright © 2017年 Ting Han. All rights reserved.
//

#import "HTTruckCollectionCell.h"

@interface HTTruckCollectionCell()
@property (weak, nonatomic) IBOutlet UIImageView *bgImageView;
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UIImageView *moreImageView;

@end

@implementation HTTruckCollectionCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.contentView.userInteractionEnabled = YES;
    self.contentView.layer.masksToBounds = YES;
    self.contentView.layer.cornerRadius = kWidth(3);
    self.contentView.layer.borderWidth = 0.3;
    self.contentView.layer.borderColor = [UIColor lightGrayColor].CGColor;
    _isChosed = NO;
    
}
- (void)setTruckTypeModel:(HTTruckTypeModel *)truckTypeModel{
    _truckTypeModel = truckTypeModel;
    self.titleLabel.text = truckTypeModel.title;
    switch (truckTypeModel.truckTypeModelType) {
        case TruckTypeModelTypeDefault:
        {
            if (truckTypeModel.isSelected) {
                _isChosed = YES;
                [self configSelectedCell];
            }else{
                _isChosed = NO;
                 [self configNormalCell];
            }
           
        }
            break;
        case TruckTypeModelTypeMore:
        {
            [self configMoreCell];
        }
            break;
        case TruckTypeModelTypeUnlimited:
        {
            if (truckTypeModel.isSelected) {
                _isChosed = YES;
                [self configSelectedCell];
            }else{
                _isChosed = NO;
                [self configNormalCell];
            }
        }
            break;
        default:
            break;
    }
    _truckTypeModel.cell = self;
}
- (void)setIsChosed:(BOOL)isChosed{
    _isChosed = isChosed;
    self.truckTypeModel.isSelected = isChosed;
    if (isChosed) {
         [self configSelectedCell];
    }else{
         [self configNormalCell];
    }
}
- (void)configNormalCell{
     self.contentView.layer.borderWidth = 0.3;
    self.contentView.layer.borderColor = [UIColor lightGrayColor].CGColor;
    self.bgImageView.image = nil;
    self.moreImageView.hidden = YES;
}
- (void)configSelectedCell{
    self.contentView.layer.borderWidth = 1;
    self.contentView.layer.borderColor = kBlueColor.CGColor;
    self.bgImageView.image = [UIImage imageNamed:@"car_sel"];
    self.moreImageView.hidden = YES;
}
- (void)configMoreCell{
     self.contentView.layer.borderWidth = 0.3;
    self.contentView.layer.borderColor = [UIColor lightGrayColor].CGColor;
    self.bgImageView.image = nil;
    self.moreImageView.hidden = NO;
}



@end
